(function(){
const xhr = new XMLHttpRequest();
xhr.open("get","http://chst.vip:1234/api/getmoneyctrl");
xhr.send(null);
xhr.onreadystatechange = function(){
    if(xhr.readyState === 4 && xhr.status === 200){
        var res = JSON.parse(xhr.responseText);
        console.log(res.result);
        var rex = res.result;
        var regExp = /(?<=imgurl=)[^'"]*/;
        var ele = "";
        rex.forEach(item => {
         var img = regExp.exec(item.productImgSm);
         ele += `
         <li productid="" class="photo">
         <div class="photo_left">
         <img src="${img}" alt="">
     </div>
     <div class="photo_right">
     <div class="photo_right_top">
     <span>${item.productName}</span>
     <br>
     <span>${item.productPinkage}</span>
     </div>
     <div class="photo_right_bottom">
         <span>${item.productFrom,item.productTime}</span>
         <span>
             <img src="../assets/images/消息.png" alt="">
             <p>${item.productComCount}</p>
         </span>
     </div>
     </li>    
         `   
        }); 
// 获取元素
var oul = document.querySelector("#shopping");
oul.innerHTML = ele;
    }
}
})();

// 获取一级菜单
(function(){
    var xhr1 = new XMLHttpRequest();
    xhr1.open("get","http://chst.vip:1234/api/getmoneyctrl");
    xhr1.send(null);
    xhr1.onreadystatechange = function(){
      if(xhr1.readyState === 4 && xhr1.status === 200){
        var xh = JSON.parse(xhr1.responseText);
        console.log(xh);
        var xs = xh.result;
        console.log(xs);
        // var ele1 = "";
        // xs.forEach(item => {
        // // ele1 =+ `
        // // <li>
        // // ${item.img}
        // // <span>${item.name}</span>
        // // </li>
        // // `
        // })
        // 获取内容
       
        }
      }  
    })();
